package com.ruoyi.web.core.utils;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.SM2;

import java.io.UnsupportedEncodingException;

/* loaded from: SM2Util.class */
public class SM2Util {
    private static final String privateKey = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQg8T0b63fn7QU+FU3mrELkELOXEIfwXT+7y/h5sgMr/PWgCgYIKoEcz1UBgi2hRANCAASu5nqyw8OaFlkwCCGJ814dz50G32xXe3WOcUaE5Fts+7hwFsR64Zk+raZicSlsAmNKTRIzK5JoJ3BIP6xhE8Fi";
    private static final String publicKey  = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEruZ6ssPDmhZZMAghifNeHc+dBt9sV3t1jnFGhORbbPu4cBbEeuGZPq2mYnEpbAJjSk0SMyuSaCdwSD+sYRPBYg==";

    public static SM2 getSM2() {
        return SmUtil.sm2(privateKey, publicKey);
    }

    public static String encryptStr(String text) {
        return getSM2().encryptBcd(text, KeyType.PublicKey);
    }

    public static String decryptStr(String encryptStr) {
        return StrUtil.utf8Str(getSM2().decryptFromBcd(encryptStr, KeyType.PrivateKey));
    }

    public static void main(String[] args) throws UnsupportedEncodingException {
    }
}
